package io.renren.modules.jxgkphone.dao;

import io.renren.modules.jxgkphone.entity.StudentInfo;
import io.renren.modules.jxgkphone.entity.TeacherUser;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/*
* create by 寇
*   用于首页中返回学生信息，还用于个人中心中信息的展示
 */
@Repository
@Mapper
public interface StuInfoMapper {
    StudentInfo GetStuInfo(@Param("student_school_id") String student_school_id);
    //临时代码 用来放学习委员数据
    @Insert("Insert into sys_user(username,password,salt,status,create_user_id,full_name) " +
            "VALUES(#{username},#{password},#{salt},#{status},#{create_user_id},#{full_name})")
    void AddStudentLeader(@Param("username")String username,
                          @Param("password")String password,
                          @Param("salt")String salt,
                          @Param("status")int status,
                          @Param("create_user_id")int create_user_id,
                          @Param("full_name")String full_name);
    @Update("UPDATE sys_user set salt=#{salt},password=#{password}")
    void UpdatePassword(@Param("salt") String salt,@Param("password") String password);
    @Select("Select user_id from sys_user WHERE username=#{username}")
    String findUserIdByUserName(String username);
    @Insert("Insert into sys_user_role(user_id,role_id) VALUES(#{user_id},#{role_id})")
    void InsertUserRole(@Param("user_id")String user_id,@Param("role_id")String role_id);
    //临时代码，用于教师用户数据
    @Select("Select teacher_id,teacher_name from teacher_info")
    List<TeacherUser> findTeacherInfo();

    @Select("Select * from student_info")
    List<StudentInfo> getAllStudent();
    String findRoleByRoleIdAndUserId(String userId,String roleId);
    @Delete("delete from sys_user where username=#{username}")
    void DeleteUserByUserName(String username);
    @Delete("delete from sys_user_role where user_id=#{userId}")
    void DeleteUserRoleByUserId(String userId);
}
